# -*- coding: utf-8 -*-
"""
系统中所有的日志的管理

"""

import logging

# global values
loggerDict = {}
ch = logging.StreamHandler()
# 创建一个handler，用于写入日志文件
fh = logging.FileHandler('all.log')

def getLogger(name):
    logger = loggerDict.get(name)
    if (logger == None):
        logger = logging.getLogger(name)
        loggerDict[name] = logger

        logger.addHandler(ch)
        logger.addHandler(fh)
        logger.setLevel(logging.INFO)

    return logger


def setLevel(name, level):
    """set level"""
    logger = getLogger(name).setLevel(level)


